suppressPackageStartupMessages({
library(tweenr)
library(gganimate)
library(tidyverse)
})
windowsFonts(Raleway = windowsFont("Raleway"))
pal1 <- c("#969457", "#357c57")
pal2 <- c("#b7e972", "#377368")
read_csv("GSB_Landings.csv", col_types = cols()) %>%
gather(Procedencia, Captura, -Year) %>%
ggplot(aes(x = Year, y = Captura, color = Procedencia)) +
geom_line(size = 1.1) +
theme_classic() +
theme(legend.justification = c(0.5, 0.5),
legend.position = c(0.7, 0.7),
text = element_text(family = "Raleway", size = 18)) +
scale_color_manual(values = pal1) +
labs(x = "Año", y = "Arribos (Toneladas)") +
scale_x_continuous(breaks = seq(1920, 2010, 10), minor_breaks = NULL) +
scale_y_continuous(breaks = seq(0, 375, 75), minor_breaks = NULL)
ggsave("Paleta1.tiff", dpi = 600, width = 16, height = 8)
read_csv("GSB_Landings.csv", col_types = cols()) %>%
gather(Procedencia, Captura, -Year) %>%
ggplot(aes(x = Year, y = Captura, color = Procedencia)) +
geom_line(size = 1.1) +
theme_classic() +
theme(legend.justification = c(0.5, 0.5),
legend.position = c(0.7, 0.7),
text = element_text(family = "Raleway", size = 20)) +
scale_color_manual(values = pal2) +
labs(x = "Año", y = "Arribos comerciales de Mero Gigante en California \n(Toneladas)") +
scale_x_continuous(breaks = seq(1920, 2010, 10), minor_breaks = NULL) +
scale_y_continuous(breaks = seq(0, 375, 75), minor_breaks = NULL)
ggsave("Paleta2.tiff", dpi = 600, width = 16, height = 8)
plot_data <- read_csv("GSB_Landings.csv", col_types = cols()) %>%
gather(Procedencia, Arribos, -Year) %>%
mutate(ease = "linear", x = Year) %>%
rename(y = Arribos, id = Procedencia, time = Year)
tween_plot <- plot_data %>%
tween_elements(., "time", "id", "ease", nframes = 250) %>% #using tweenr!
mutate(year = round(time), id = .group) %>%
left_join(plot_data, by = c("time", "y", "x", "id")) %>%
rename(Procedencia = id) %>%
ggplot(aes(x = x, y = y, frame = .frame, color = Procedencia)) +
geom_path(aes(group = Procedencia, cumulative = T), size = 1.1) +
theme_classic() +
theme(legend.justification = c(0.5, 0.5),
legend.position = c(0.7, 0.7),
text = element_text(family = "Raleway", size = 18)) +
scale_color_manual(values = pal1) +
labs(x = "Año", y = "Arribos (Toneladas)") +
scale_x_continuous(breaks = seq(1920, 2010, 10), minor_breaks = NULL) +
scale_y_continuous(breaks = seq(0, 375, 75), minor_breaks = NULL)
Column `id` joining factor and character vector, coercing into character vectorIgnoring unknown aesthetics: cumulative
gganimate(tween_plot, title_frame = FALSE, interval = 0.001, "Landings_CA.gif", ani.width = 800, ani.height = 500)
read_csv("GSB_Landings_mx.csv", col_types = cols()) %>%
ggplot(aes(x = Ano, y = Arribos)) +
geom_line(size = 1.1, color = "#357c57") +
geom_point(size = 2, color = "#357c57") +
theme_classic() +
theme(legend.justification = c(0.5, 0.5),
legend.position = c(0.7, 0.7),
text = element_text(family = "Raleway", size = 20)) +
labs(x = "Año", y = "Arribos comerciales de Mero Gigante \n(Toneladas)")
ggsave("Mex.tiff", dpi = 600, width = 16, height = 8)
bio <- read.csv(file = "records.csv", stringsAsFactors = F) %>%
select(Species, Site, Sale_price_pkg, Fish_Market_name, Catch_site, Pesca_Objetivo, Weight, Total_Length, Head_Length, Weight_notes, Otoliths, Collector) %>%
magrittr::set_colnames(value = tolower(colnames(.)))
colectores <- group_by(bio, site, collector) %>%
count() %>%
ggplot(aes(x = collector, y = n)) +
geom_col(aes(fill = site), color = "black") +
cowplot::theme_cowplot() +
theme(legend.justification = c(1, 1),
legend.position = c(0.9, 0.9)) +
scale_fill_brewer(palette = "Set1") +
ggExtra::rotateTextX()
plotly::ggplotly(colectores)
model <- lm(log10(weight)~log10(total_length), data = bio)
tidy_model <- broom::tidy(model)
glance_model <- broom::glance(model)
text_linear <- c("log10(TW) = -5.0363 + log10(TL)^3.1198")
text_exp <- c("TW = 10^(-5.0363)*(TL^3.1198)")
line <- data.frame(x = seq(0, 210, by = 1)) %>%
mutate(y = 10^(-5.0363)*(x^3.1198))
LW <- filter(bio, !is.na(total_length),
!is.na(weight)) %>%
mutate(weight_notes = ifelse(is.na(weight_notes), "No notes", weight_notes),
site = ifelse(is.na(site), "Missing", site)) %>%
ggplot(aes(x = total_length, y = weight)) +
geom_point(size = 2, alpha = 0.5, aes(color = weight_notes, site = site, otolitos = otoliths)) +
scale_color_brewer(palette = "Set1", direction = -1) +
labs(x = "Total Length (cm)", y = "Total Weight (Kg)") +
ggtitle(text_exp) +
geom_line(data = line, aes(x = x, y = y))
Ignoring unknown aesthetics: site, otolitos
plotly::ggplotly(LW)
LW <- filter(bio, !is.na(total_length),
!is.na(weight)) %>%
mutate(weight_notes = ifelse(is.na(weight_notes), "No notes", weight_notes),
site = ifelse(is.na(site), "Missing", site)) %>%
ggplot(aes(x = log10(total_length), y = log10(weight), color = weight_notes, site = site, otolitos = otoliths, Weight = weight, Length = total_length)) +
geom_point(size = 2, alpha = 0.5) +
scale_color_brewer(palette = "Set1", direction = -1) +
labs(x = "Total Length (cm)", y = "Total Weight (Kg)") +
ggtitle(text_linear) +
geom_abline(slope = 3.1198, intercept = -5.0363)
plotly::ggplotly(LW)